from tortoise import fields, models
class User(models.Model):
    id = fields.IntField(pk=True, description="主键")
    username = fields.CharField(max_length=255, unique=True, description="用户名")
    nickname = fields.CharField(max_length=255, index=True, description="昵称")
    password = fields.CharField(max_length=255, description="密码")
    openid = fields.CharField(max_length=255, unique=True, description="微信openid")
    mobile = fields.CharField(max_length=20, index=True, description="手机号")
    avatar = fields.CharField(max_length=500, null=True, description='头像')
    country = fields.CharField(max_length=255, null=True, description='国家')
    province = fields.CharField(max_length=255, null=True, description='省份')
    city = fields.CharField(max_length=255, null=True, description='城市')
    sex = fields.BooleanField(default=True, null=True, description='性别')
    created_time = fields.DatetimeField(auto_now_add=True, description='创建时间')
    updated_time = fields.DatetimeField(auto_now=True, description="更新时间")
    deleted_time = fields.DatetimeField(null=True, description="删除时间")
    is_active = fields.BooleanField(default=True, description="是否激活")
    is_superuser = fields.BooleanField(default=False, description="是否超级管理员")

    class Meta:
        table = "kj_users"
        table_description = "用户表"

    def __repr__(self):
        return f"User(id={self.id}, username={self.username})"

    __str__ = __repr__